﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using FluentValidation;
using CashFlow.Web.Models.Account;
using CashFlow.Web.Common;

namespace CashFlow.Web.Validator.Account
{
    public class RegisterUserInfoModelValidator
        : AbstractValidator<RegisterUserInfoModel>
    {
        public RegisterUserInfoModelValidator()
        {
            RuleFor(x => x.Phone)
                .Must(x => RegExpTool.IsPhone(x))
                .WithMessage("手机号码格式不正确！");
            RuleFor(x => x.Pwd)
                .Must(x => RegExpTool.IsPassword(x))
                .WithMessage("密码格式不正确！");
            RuleFor(x => x.Name)
                .Must(x => RegExpTool.IsName(x))
                .WithMessage("姓名格式不正确！");
            RuleFor(x => x.ReferenceInvitationCode)
                .Must(x => RegExpTool.IsInvitationCode(x))
                .WithMessage("推荐人邀请码格式不正确！");
            RuleFor(x => x.VerifyCode)
                .Must(x => RegExpTool.IsVerifyCode(x))
                .WithMessage("验证码格式不正确！");
        }
    }
}